package org.wattdepot.cli.command;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the ListSummary class.
 * 
 * @author Yichi Xu
 *
 */
public class TestSummaryCommand extends CommandTestBed {
  /** 
   * Tests the doCommand method of ListSummaryCommand.
   * 
   * @see org.wattdepot.cli.command.CommandTestBed#testDoCommand()
   */
  @Test
  @Override
  public void testDoCommand() {
    String command;
    String result;
    
    SummaryCommand listCommand = new SummaryCommand(this.client);
    
    // Sad tests
    command = "summary SIM_KAHE foo";
    result = listCommand.doCommand(command);
    assertTrue("Checking that the command is invalid.", 
        result.startsWith(WattDepotCliCommand.PARAMETER_COUNT_ERROR));
    
    command = "summary foo";
    result = listCommand.doCommand(command);
    assertTrue("Checking that the source is invalid.", 
        result.startsWith(WattDepotCliCommand.SOURCE_ERROR));
    
    // Happy tests
    command = "summary SIM_KAHE";
    result = listCommand.doCommand(command);
    assertTrue("Checking that there is word Owner in the result",
        result.contains("Owner"));
    assertFalse("Checking that the command is valid.", 
        result.equals(WattDepotCliCommand.reportUnknownCommand(command)));
    assertFalse("Checking that the source is valid.",
        result.startsWith(WattDepotCliCommand.SOURCE_ERROR));
  }
}
